package com.wyh.mapper;

import com.wyh.entity.Repairstatus;
import com.wyh.utils.sqlUtils.repairstatus.addRepairStatusSqlDynamic;
import com.wyh.utils.sqlUtils.repairstatus.updateRepairStatusSqlDynamic;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface RepiarstatusMapper {
    //根据id查询报修信息
    @Select(" SELECT repairstatus.id, issue, type, progress, priority, h.house_id,h.address,u.uid, u.name, time, repairstatus.remark " +
            "FROM repairstatus " +
            " left join communitymanagementsystem.house h on repairstatus.house_id_fk = h.house_id " +
            " left join communitymanagementsystem.user u on repairstatus.repair_user_id_fk = u.uid " +
            "WHERE id = #{id}")
    Repairstatus findRepairStatusById(@Param("id") int id);
    //查询所有报修信息
    @Select(" SELECT repairstatus.id, issue, type, progress, priority, h.house_id,h.address,u.uid, u.name, time, repairstatus.remark  " +
            "FROM repairstatus " +
            " left join communitymanagementsystem.house h on repairstatus.house_id_fk = h.house_id " +
            " left join communitymanagementsystem.user u on repairstatus.repair_user_id_fk = u.uid")
    List<Repairstatus> getAllRepairStatus();
    //添加报修信息
    @InsertProvider(type = addRepairStatusSqlDynamic.class , method = "addDynamic")
    void addRepairStatus(Repairstatus repairstatus);
    //修改报修信息
    @UpdateProvider(type = updateRepairStatusSqlDynamic.class , method = "updateDynamic")
    void updateRepairStatus(Repairstatus repairstatus);
    //删除报修信息
    @Delete("DELETE FROM repairstatus WHERE id = #{id}")
    void deleteRepairStatus(@Param("id") int id);
}
